package com.atguigu.upp.service;

import com.atguigu.upp.bean.TagInfo;
import com.atguigu.upp.bean.TaskInfo;
import com.atguigu.upp.bean.TaskTagRule;
import com.atguigu.upp.mapper.ClickhouseMapper;
import com.atguigu.upp.mapper.TagInfoMapper;
import com.atguigu.upp.mapper.TaskInfoMapper;
import com.atguigu.upp.mapper.TaskTagRuleMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * Created by Smexy on 2022/11/11
 *
 *      把常用的查询Mysql的方法集成
 */
public class CKDBService
{

    private ClickhouseMapper clickhouseMapper;


    public CKDBService(SqlSession sqlSession){
        clickhouseMapper = sqlSession.getMapper(ClickhouseMapper.class);

    }

    public void dropTable(String table){
        if (StringUtils.isBlank(table)){
            throw new RuntimeException("表名非法!");
        }
        clickhouseMapper.dropTable(table);
    }

    public void createTable(String table,String column){
        if (StringUtils.isBlank(table) || StringUtils.isBlank(column)){
            throw new RuntimeException("参数非法!");
        }
        clickhouseMapper.createTable(table,column);
    }

    public void insertBitmapSql(String table,String dt,String tagSql,String source){
        if (StringUtils.isBlank(table) || StringUtils.isBlank(dt) ||  StringUtils.isBlank(tagSql) || StringUtils.isBlank(source) ){
            throw new RuntimeException("参数非法!");
        }
        clickhouseMapper.insertBitmapSql(table,dt,tagSql,source);
    }

    public void deleteBitMapData(String table,String dt){
        if (StringUtils.isBlank(table) || StringUtils.isBlank(dt) ){
            throw new RuntimeException("参数非法!");
        }
        clickhouseMapper.deleteBitMapData(table,dt);
    }
}
